﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Main.src.display
{

    /// <summary>
    /// Permite desenhar um texto na tela
    /// </summary>
    public sealed class Label : DisplayObject
    {

        public SpriteFont SpriteFont = Main.self.Content.Load<SpriteFont>("Arial"); // Fonte
        public string     Text       = "";                                          // Texto

        /// <summary>
        /// Construtor
        /// </summary>
        /// <param name="text">Texto</param>
        public Label(string text = null)
        {
            if (text != null)
                Text = text;
        }

        /// <summary>
        /// Desenha na tela
        /// </summary>
        /// <param name="spriteBatch">SpriteBatch do Main</param>
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (Invisible)
                return;
            spriteBatch.DrawString(SpriteFont, Text, Position, Color, Rotation, Origin, Scale, Effects, LayerDepth);
        }

        /// <summary>
        /// Destrutor
        /// </summary>
        public override void Dispose()
        {
            base.Dispose();
            SpriteFont = null;
        }

        /// <summary>
        /// Pega o tamanho do texto
        /// </summary>
        public Vector2 Size
        {
            get
            {
                return SpriteFont.MeasureString(Text);
            }
        }

        /// <summary>
        /// Pega a largura do texto
        /// </summary>
        public float Width
        {
            get
            {
                return Size.X;
            }
        }

        /// <summary>
        /// Pega a altura do texto
        /// </summary>
        public float Height
        {
            get
            {
                return Size.Y;
            }
        }

    }

}